package cn.itcast.order.config;

import cn.itcast.order.handler.ProjectInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

//添加拦截器并设定拦截的访问路径，路径可以通过可变参数设置多个
@Configuration
public class SpringMvcSupport extends WebMvcConfigurationSupport {
    //TODO
    @Autowired
    private ProjectInterceptor projectInterceptor;
    
    //静态资源放行
    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
//        registry.addResourceHandler("/pages/**").addResourceLocations("/pages/");
    }

    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        //TODO: 配置拦截器
        registry.addInterceptor(projectInterceptor).addPathPatterns("/order","/order/**","/address/**");
    }
}